﻿using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using WFramework;

namespace MiniWeb.Web.Controllers.Web.ValidateCodes
{
    public class ValidateCodesController : BaseController
    {
        private readonly ValidateCodeService _validateCodeService = new ValidateCodeService();

        public void Create()
        {
            var image = _validateCodeService.CreateCode();
            image.Save(Response.OutputStream, ImageFormat.Jpeg);

        }

        public void Create1()
        {
           
            var bytes = _validateCodeService.CreateCode2(80,30);
            Response.ContentType = "image/jpeg";
            Response.BinaryWrite(bytes);
        }

        public ActionResult Check(string validateCode)
        {
            var isOK = _validateCodeService.CheckCode(validateCode);
            return Json(isOK, JsonRequestBehavior.AllowGet);
        }
    }
}
